import request from './';

export function signUp({ username, password, ...rest }) {
  const data = Object.assign({ username, password }, rest);
  return request.post('/users', { data });
}

export function login({ username, password } = {}) {
  return request.get('/login', { params: { username, password } });
}

export function logout(sessionToken) {
  return request.post('/logout', { sessionToken });
}

export function loadUserBySessionToken(sessionToken) {
  return request.get('/users/me', { sessionToken });
}
